/*
 * @Author: HeAo
 * @Date: 2021-11-01 16:45:13
 * @LastEditTime: 2021-11-01 16:58:15
 * @LastEditors: HeAo
 * @Description:
 * @FilePath: \web2103-2105\web2105\4-1-Nodejs\day02\3-event.js
 * 别乱动！
 */
let EventEmmiter = require('events');

class MyEmmiter extends EventEmmiter {

}

let emmiter = new MyEmmiter()

emmiter.on('touch', () => {
  console.log('BMW');
})
const handler = () => {
  console.log('点击');
}
emmiter.on('click', handler)

emmiter.off('click', handler)

console.log(emmiter.eventNames());
console.log(emmiter.listeners('touch'));

// 通过编程式的形式，模拟触发emmiter上绑定的touch事件
emmiter.emit('touch')
